<?php
/*********************************************************************************
* Filename: get_team.php
* 
* This PHP script grabs a team id and team name from the database and sends an
* email to the team owner with a link to reset their team password
*
* Author: Caleb Goff
* Date Created: 11/15/2009
**********************************************************************************/

//Include common.php to utilize common functions
include_once 'common.php';
require_once "Mail.php";
//Retrieve variables from HTTP POST
$league_id      = $_REQUEST['leagueId'];
$team_email     = $_REQUEST['teamEmail'];
$hash		    = $_REQUEST['verify'];

$retVal = 0;

// Query the database to get the team id and name with the league id and email
$query = "SELECT TEAM_ID, TEAM_NAME FROM TEAMS WHERE LEAGUE_ID = '$league_id' AND OWNER_EMAIL = '$team_email'";
$result = do_query($query, $g_db_name, $g_username);
$row = mysql_fetch_assoc($result);

if (!$row)
{
	$retVal = 1;
}

$team_id = $row['TEAM_ID'];
$team_name = $row['TEAM_NAME'];

if ($retVal == 0){

	// Define the body of the team creation notification email
	$body = "Hello!\n
		 This email is being sent to you because you requested to reset your team password for $team_name.

		 $g_server/retrieve_password.php?mode=question&key=$hash

		 - The Fantasy Broomball Team";

	// Send out the email
	email_message($team_creation_subject,$body,$team_email);

}

echo $retVal;

?>

